import { createStore } from 'vuex'

export default createStore({
  state: {
    // 存储token
    Token: localStorage.getItem('token') ? localStorage.getItem('token') : '',
    // 存储登录用户信息
    UserInfo: localStorage.getItem('user') ? localStorage.getItem('user') : ''
  },
  getters: {
  },
  mutations: {
    //注册处理函数，在login组件的login方法上使用this.$store.commit('login',data);
    loginToken(state, token) {
      state.Token = token;
      localStorage.setItem('token', token)
    },
    LoginUser(state, user) {
      state.UserInfo = user;
      localStorage.setItem('user', user)
    }    
  },
  actions: {
  },
  modules: {
  }
})
